package com.jl.jlapp.mvp.activity;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import com.jl.jlapp.R;
import com.jl.jlapp.eneity.MessageNoReadNumModel;
import com.jl.jlapp.eneity.MessageNoReadNumModel.ResultDataBean;
import com.jl.jlapp.eneity.PostModel;
import com.jl.jlapp.nets.Api;
import com.jl.jlapp.nets.CommonObserver;
import com.jl.jlapp.nets.Net;
import com.jl.jlapp.nets.Transformer;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import java.text.SimpleDateFormat;

public class MessageCenterActivity extends Activity {
    @BindView(R.id.activity_last_time)
    TextView activityLastTimeTv;
    String activityMessageLastActivityName = "";
    long activityMessageLastTime = 0L;
    @BindView(R.id.activity_message_no_read_num)
    TextView activityMessageNoReadNumTv;
    int activityMessageNum = 0;
    @BindView(R.id.activity_no_message)
    TextView activityNoMessage;
    @BindView(R.id.last_activity_name)
    TextView lastActivityNameTv;
    @BindView(R.id.last_order_no)
    TextView lastOrderNoTv;
    @BindView(R.id.order_has_message_linear)
    LinearLayout orderHasMessageLinear;
    @BindView(R.id.order_last_time)
    TextView orderLastTimeTv;
    String orderMessageLastOrderNo = "";
    long orderMessageLastTime = 0L;
    int orderMessageNoReadNum = 0;
    @BindView(R.id.order_message_no_read_num)
    TextView orderMessageNoReadNumTv;
    @BindView(R.id.order_no_message)
    TextView orderNoMessage;
    private ProgressDialog progressDialog;
    long serviceLastTime = 0L;
    @BindView(R.id.service_message_no_read_num)
    TextView serviceMessageNoReadNumTv;
    int serviceNoReadNum = 0;
    @BindView(R.id.service_point)
    TextView servicePointTv;
    SimpleDateFormat simpleDateFormat;
    int userId = -1;

    private void setMessage(MessageNoReadNumModel paramMessageNoReadNumModel) {
        Log.d("aaaaaaaaaaaa", paramMessageNoReadNumModel.getResultData().getOrderTime() + "  getOrderTime");
        Log.d("aaaaaaaaaaaa", paramMessageNoReadNumModel.getResultData().getActivityTime() + "  getActivityTime");
        if (paramMessageNoReadNumModel.getResultData().getOrderTime() > 0L) {
            Log.d("aaaaaaaaaaaa", "if");
            this.orderNoMessage.setVisibility(View.GONE);
            this.orderHasMessageLinear.setVisibility(View.VISIBLE);
            this.orderLastTimeTv.setText(this.simpleDateFormat.format(Long.valueOf(paramMessageNoReadNumModel.getResultData().getOrderTime())));
            this.lastOrderNoTv.setText(paramMessageNoReadNumModel.getResultData().getOrderNO());
            this.orderLastTimeTv.setVisibility(View.VISIBLE);
        }
        if (paramMessageNoReadNumModel.getResultData().getActivityTime() > 0L) {
            this.activityNoMessage.setVisibility(View.GONE);
            this.lastActivityNameTv.setVisibility(View.VISIBLE);
            this.lastActivityNameTv.setText(paramMessageNoReadNumModel.getResultData().getActivityName());
            this.activityLastTimeTv.setText(this.simpleDateFormat.format(Long.valueOf(paramMessageNoReadNumModel.getResultData().getActivityTime())));
            this.activityLastTimeTv.setVisibility(View.VISIBLE);
            Log.d("aaaaaaaaaaaa", "else");
            this.orderHasMessageLinear.setVisibility(View.GONE);
            this.orderNoMessage.setVisibility(View.VISIBLE);
            this.orderLastTimeTv.setVisibility(View.GONE);
        }
        this.activityNoMessage.setVisibility(View.VISIBLE);
        this.lastActivityNameTv.setVisibility(View.GONE);
        this.activityLastTimeTv.setVisibility(View.GONE);
    }

    private void setNoReadMessageNum() {
        this.serviceMessageNoReadNumTv.setVisibility(View.GONE);
        if (this.orderMessageNoReadNum > 0) {
            this.orderMessageNoReadNumTv.setText(this.orderMessageNoReadNum + "");
            this.orderMessageNoReadNumTv.setVisibility(View.VISIBLE);
        }
        if (this.activityMessageNum > 0) {
            this.activityMessageNoReadNumTv.setText(this.activityMessageNum + "");
            this.activityMessageNoReadNumTv.setVisibility(View.VISIBLE);
            this.orderMessageNoReadNumTv.setVisibility(View.GONE);
        } else {
            this.activityMessageNoReadNumTv.setVisibility(View.GONE);
        }
    }

    public void buildProgressDialog() {
        if (this.progressDialog == null) {
            this.progressDialog = new ProgressDialog(this);
            this.progressDialog.setProgressStyle(0);
        }
        this.progressDialog.setMessage("加载中");
        this.progressDialog.setCancelable(true);
        this.progressDialog.show();
    }

    public void cancelProgressDialog() {
        if ((this.progressDialog != null) && (this.progressDialog.isShowing())) {
            this.progressDialog.dismiss();
        }
    }

    public void getMessageNum(Integer paramInteger) {
        Net.get().getMessageNum(paramInteger.intValue())
                .compose(Transformer.<MessageNoReadNumModel>switchSchedulers())
                .subscribe(new CommonObserver<MessageNoReadNumModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(MessageNoReadNumModel messageNoReadNumModel) {

                    }
                });
    }

    @OnClick({R.id.icon_return, R.id.message_setting_img, R.id.order_message_rela, R.id.user_service_rela, R.id.activity_message_rela})
    public void onClick(View paramView) {
        switch (paramView.getId()) {
            case R.id.icon_return:
                finish();
                return;
            case R.id.message_setting_img:
                startActivity(new Intent(this, MessageSettingsActivity.class));
                return;
            case R.id.order_message_rela:
                updateOrderMSGStauts(Integer.valueOf(this.userId));
                return;
            case R.id.user_service_rela:
                startActivity(new Intent(this, CustomerServiceActivity.class));
                return;
        }
    }

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.activity_message_center);
        ButterKnife.bind(this);
        this.simpleDateFormat = new SimpleDateFormat("M月d日");
    }

    protected void onResume() {
        super.onResume();
        this.userId = getSharedPreferences("JLAppData", 0).getInt("userId", -1);
        buildProgressDialog();
        if (this.userId > 0) {
            getMessageNum(Integer.valueOf(this.userId));
            return;
        }
        Toast.makeText(this, "您还未登录，请先登录。", Toast.LENGTH_SHORT).show();
        startActivity(new Intent(this, LoginActivity.class));
    }

    public void updateActivityMSGStauts(Integer paramInteger) {
        Net.get().updateActivityMSGStauts(paramInteger.intValue())
                .compose(Transformer.<PostModel>switchSchedulers())
                .subscribe(new CommonObserver<PostModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(PostModel postModel) {

                    }
                });
    }

    public void updateOrderMSGStauts(Integer paramInteger) {
        Net.get().updateOrderMSGStauts(paramInteger.intValue())
                .compose(Transformer.<PostModel>switchSchedulers())
                .subscribe(new CommonObserver<PostModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(PostModel postModel) {

                    }
                });
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/MessageCenterActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */